package com.tadpole.music.holder.me;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.home.ClockInBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.DateUtils;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/12/9
 */
public class V2DayViewHolder extends BaseViewHolder {
    private View itemView;
    private List<ClockInBean> list;
    private TextView tvWeek;
    private Activity activity;
    private TextView thisDay;
    private int p;
    private BaseAdapter.OnItemClickListener onItemClickListener;

    public V2DayViewHolder(Activity activity, View itemView, List<ClockInBean> list, int p, BaseAdapter.OnItemClickListener onItemClickListener) {
        super(itemView);
        this.activity = activity;
        this.itemView = itemView;
        this.list = list;
        this.p = p;
        this.onItemClickListener = onItemClickListener;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void init(final int position) {
        tvWeek = itemView.findViewById(R.id.tvWeek);
        thisDay = itemView.findViewById(R.id.thisDay);

        tvWeek.setText(list.get(position).getDay()+"");

        if(list.get(position).getDay()==0){
            tvWeek.setVisibility(View.GONE);
            thisDay.setVisibility(View.GONE);
        }else{
            tvWeek.setVisibility(View.VISIBLE);
            if(list.get(position).isClock()){
                tvWeek.setTextColor(activity.getResources().getColor(R.color.color_yellow));
            }else{
                tvWeek.setTextColor(activity.getResources().getColor(R.color.color_aaa));
            }
            if(list.get(position).getDay()== DateUtils.getDay()){
                if(p==0){
                    thisDay.setVisibility(View.VISIBLE);
                    tvWeek.setTextColor(activity.getResources().getColor(R.color.white));
                }else{
                    thisDay.setVisibility(View.GONE);
                }
            }else{
                thisDay.setVisibility(View.GONE);
            }

        }

        if(list.get(position).isNext()){
            tvWeek.setTextColor(activity.getResources().getColor(R.color.color_66));
        }

        itemView.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onItemClickListener.onItemClick(itemView,position);
            }
        });
    }
}
